What is a good way to refactor a large, terribly written code base by myself? [closed]

Posted by AgentKC on Programmers See other posts from Programmers or by AgentKC
Published on 2011-12-15T16:31:06Z Indexed on 2012/03/25 5:39 UTC
Read the original article Hit count: 216

Possible Duplicate:
Techniques to re-factor garbage and maintain sanity?

I have a fairly large PHP code base that I have been writing for the past 3 years. The problem is, I wrote this code when I was a terrible programmer and now it's tens of thousands of lines of conditionals and random MySQL queries everywhere. As you can imagine, there are a ton of bugs and they are extremely hard to find and fix.

So I would like a good method to refactor this code so that it is much more manageable. The source code is quite bad; I did not even use classes or functions when I originally wrote it. At this point, I am considering rewriting the whole thing.

I am the only developer and my time is pretty limited. I would like to get this done as quickly as possible, so I can get back to writing new features. Since rewriting the code would take a long time, I am looking for some methods that I can use to clean up the code as quickly as possible without leaving more bad architecture that will come back to haunt me later.

So this is the basic question: What is a good way for a single developer to take a fairly large code base that has no architecture and refactor it into something with reasonable architecture that is not a nightmare to maintain and expand?

© Programmers or respective owner

Related posts about web-development

Related posts about architecture